//
//  YXLoginView.m
//  跑跑快销
//
//  Created by 杨潇 on 14-4-28.
//  Copyright (c) 2014年 ylife. All rights reserved.
//

#import "YXLoginView.h"

@implementation YXLoginView
@synthesize numberText,passwordText,loginBtn,forgetBtn,registerBtn;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self.backgroundColor = [UIColor grayColor];
        [self createUI];
    }
    return self;
}

#pragma mark - CreateUI

- (void)createUI
{
    int textH = 40;
    int textW = 260;
    int numberTextY;
    
    if (ISDEVICE7) {
        numberTextY = 120;
    }else{
        numberTextY = 100;
    }
    
    self.numberText = [[UITextField alloc] initWithFrame:CGRectMake(30, numberTextY, textW, textH)];
    UIView * vi = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 25, 25)];
    vi.backgroundColor = [UIColor blackColor];
    self.numberText.leftView = vi;
    self.numberText.leftViewMode = UITextFieldViewModeAlways;
    self.numberText.placeholder = @"手机号码";
    self.numberText.font = [UIFont systemFontOfSize:15];
    self.numberText.backgroundColor = [UIColor clearColor];
    self.numberText.borderStyle = UITextBorderStyleRoundedRect;
    self.numberText.keyboardType = UIKeyboardTypeNumberPad;
    [self addSubview:self.numberText];
    
    self.passwordText = [[UITextField alloc] initWithFrame:CGRectMake(30, numberTextY + textH + 20, textW, textH)];
    self.passwordText.secureTextEntry = YES;
    self.passwordText.placeholder = @"密码";
    self.passwordText.font = [UIFont systemFontOfSize:15];
    self.passwordText.backgroundColor = [UIColor clearColor];
    self.passwordText.borderStyle = UITextBorderStyleRoundedRect;
    self.passwordText.keyboardType = UIKeyboardTypeAlphabet;
    [self addSubview:self.passwordText];
    
    self.loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.loginBtn setTitle:@"登录" forState:UIControlStateNormal];
    [self.loginBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.loginBtn.backgroundColor = [UIColor redColor];
    self.loginBtn.frame = CGRectMake(30, self.passwordText.frame.origin.y + textH + 50, textW, textH);
    [self addSubview:self.loginBtn];
    
    NSString * forgetBtnTitle = @"忘记密码";
    self.forgetBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.forgetBtn setTitle:forgetBtnTitle forState:UIControlStateNormal];
    [self.forgetBtn setTitleColor:[UIColor brownColor] forState:UIControlStateNormal];
    self.forgetBtn.titleLabel.font = [UIFont boldSystemFontOfSize:15];
    self.forgetBtn.frame = CGRectMake(130, self.loginBtn.frame.origin.y + textH + 5, 60, 20);
    [self addSubview:self.forgetBtn];
    
    self.registerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.registerBtn setTitle:@"注册新账户" forState:UIControlStateNormal];
    [self.registerBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.registerBtn.backgroundColor = [UIColor redColor];
    self.registerBtn.frame = CGRectMake(30, self.forgetBtn.frame.origin.y + 20 + 50, textW, textH);
    [self addSubview:self.registerBtn];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
